package com.java.collection;

import java.sql.SQLOutput;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class CollectionDemo {
    public static void main(String[] args) {
        List<Integer> list = new ArrayList<>();

        list.add(1);
        list.add(2);
        list.add(3);
        list.add(4);
        list.add(5);
        //排序
        Collections.sort(list);
        //二分查找
        int pos = Collections.binarySearch(list,2);
        System.out.println("找到位置："+pos);
        //反转
        Collections.reverse(list);
        for (Integer num : list){
            System.out.println(num);
        }
        System.out.println("----------------");
        //打乱
        Collections.shuffle(list);
        for (Integer num : list){
            System.out.println(num);
        }
        System.out.println("----------------");
        int max = Collections.max(list);
        System.out.println("最大值："+max);
    }

}
